﻿using System;
using System.Collections.Generic;
using System.Text;

namespace WsProtocol.IEC62056
{
    // hxh 2018-5 62056
    
    public enum enumData
    {
        NULL = 0,
        array = 1,
        structure = 2,
        boolean = 3,
        bit_string = 4,
        double_long = 5,
        double_long_unsigned = 6,
        octet_string = 9,
        visible_string = 10,
        utf8_string = 12,
        bcd = 13,
        integer = 15,
        Long = 16,
        unsigned = 17,
        long_unsigned = 18,
        compact_array = 19,
        long64 = 20,
        long64_unsigned = 21,
        Enum = 22,
        float32 = 23,
        float64 = 24,
        date_time = 25,
        date = 26,
        time = 27,
        //datetimes = 28,        
        CAD = 81,
        COMDCB = 95,//非协议文件中规定,自定义的
        ScalerUnit = 89,
        ModuleParas = 245,
        MKEncrypt = 246,      //hxh 2019-4-22 更新密钥时用主密钥对密钥进行加密
        TokenEnterData = 247, //Token数据处理，自定义不定长十进制字符串转成十六进制
        CHOICE = 248, 
        OBIS = 249,
        SUnit = 250,
        Data = 255 
         
    }

    public enum DataTypeLen  //某些数据类型的字节数
    {
        NULL = 0,
        array = 0,
        structure = 0,
        boolean = 1,
        bit_string = 0,
        double_long = 4,
        double_long_unsigned = 4,
        octet_string = 0,
        visible_string = 0,
        utf8_string = 0,
        integer = 1,
        Long = 2,
        unsigned = 1,
        long_unsigned = 2,
        long64 = 8,
        long64_unsigned = 8,
        Enum = 1,
        float32 = 4,
        float64 = 8,
        date_time = 12,
        date = 5,
        time = 4,

        //非协议文件中规定,自定义的
        //datetimes = 9,
        CAD = 9,
        COMDCB = 0,
        ScalerUnit = 2,
        OBIS = 6,
        SUnit = 1,
        CHOICE = 1,
        Data = 0
    }


    public enum DataTypeInputLen 
    //某些数据类型的输入数据长度
    {
        NULL = 0,
        array = 0,
        structure = 0,
        boolean = 2,
        bit_string = 0,
        double_long = 11,
        double_long_unsigned = 10,
        octet_string = 0,
        visible_string = 0,
        utf8_string = 0,
        integer = 4,
        ilong = 6,
        unsigned = 3,
        long_unsigned = 5,
        long64 = 21,
        long64_unsigned = 20,
        Enum = 2,
        float32 = 8,
        float64 = 16,
        date_time = 37,
        date = 10,
        time = 8,
       // datetimes = 18,
        CAD = 18,
        COMDCB = 0,
        ScalerUnit = 4,
        OBIS = 23,
        SUnit = 2,
        CHOICE = 2,
        Data = 0 //非协议文件中规定,自定义的
    }
  
    //public enum ApduPath
    //{
    //    PlainApdu = 0,　//明文通道
    //    ScurityApdu = 1 //安全认证通道
    //}

    public enum ClientApduSel
    {
        InitiateRequest = 1,     

        ConnectRequest = 96,      //建立应用连接请求	CONNECT-Request,  

        ReleaseRequest = 98,     //应用层断开连接请求

        DLConnectRequest = 129,   //建立链路层连接请求，如果有用户信息，则为81 80. 取81

        DLReleaseRequest = 0,   //连路层断开连接请求

        GETRequest = 192,          //读取请求			GET-Request，

        SETRequest = 193,         //设置请求 			SET-Request，

        EventRequest =194,       // IMPLICIT EventNotificationRequest,

        ActionRequest = 195,      //操作请求 			ACTION-Request，    

        //全局加密的pdu
        gloInitiateRequest = 33,

     	gloGetRequest = 200,          //    	[200] IMPLICIT 	OCTET STRING,

     	gloSetRequest = 201,          //IMPLICIT   	OCTET STRING,

     	gloEventNotiRrequest = 202,   //IMPLICIT   	OCTET STRING,

     	gloActionRequest = 203,       //IMPLICIT   	OCTET STRING,
        //专用加密的pdu    
        dedGetRequest = 208,           //IMPLICIT   	OCTET STRING,

     	dedSetRequest = 209,          //IMPLICIT   	OCTET STRING,

     	dedEventNotiRequest = 210,    //IMPLICIT   	OCTET STRING,

     	dedActionRequest = 211,          //IMPLICIT   	OCTET STRING,

        AccessRequest = 217,          // IMPLICIT Access-Request,

        Generalglocipher = 219,      //general-glo-ciphering [219] IMPLICIT General-Glo-Ciphering,
        Generaldedcipher = 220,      //general-ded-ciphering [220] IMPLICIT General-Ded-Ciphering,
        Generalcipher = 221,         //general-ciphering [221] IMPLICIT General-Ciphering,
        Generalsigning = 223,        //general-signing [223] IMPLICIT General-Signing,
        Generalblocktransfer = 224,  //general-block-transfer [224] IMPLICIT General-Block-Transfer
        gloReportRequest = 56,
        dedReportRequest = 88,
        ReportRequest = 24,
    }

    public enum ServerApduSel
    {
        InitiateResponse = 8,

        ConnectResponse = 97,         //建立应用连接响应	    [130]	CONNECT-Response，

        ReleaseResponse = 99,       //应用层断开响应

        DLConnectResponse = 129,     //建立链路层连接响应，如果有用户信息，则为81 80. 取81

        GETResponse = 196,            //读取响应           	[133]	GET-Response，

        SETResponse = 197,            //设置响应       	    [134]	SET-Response，

        ActionResponse = 199,         //操作响应        	    [135]	ACTION-Response，

        gloInitiateResponse = 40,

        gloGetResponse = 204,        //IMPLICIT   	OCTET STRING,

        gloSetResponse = 205,       //IMPLICIT   	OCTET STRING,

     	gloActionResponse = 207,    //IMPLICIT   	OCTET STRING,

        dedGetResponse =212,        //IMPLICIT   	OCTET STRING,

     	dedSetResponse =213,         //IMPLICIT   	OCTET STRING,

     	dedActionResponse=215,          //IMPLICIT   	OCTET STRING

        exResponse = 216,          //IMPLICIT ExceptionResponse
      
        AccessResponse = 218,     // IMPLICIT Access-Response,

        DataNotification = 15,    //0F        

        Generalglocipher = 219,      //general-glo-ciphering [219] IMPLICIT General-Glo-Ciphering,
        Generaldedcipher = 220,      //general-ded-ciphering [220] IMPLICIT General-Ded-Ciphering,
        Generalcipher = 221,         //general-ciphering [221] IMPLICIT General-Ciphering,
        Generalsigning = 223,        //general-signing [223] IMPLICIT General-Signing,
        Generalblocktransfer = 224,  //PushBlockResponse = 224,   //E0  Push分帧 general-block-transfer [224] IMPLICIT General-Block-Transfer
        gloReportRequest = 56,
        dedReportRequest = 88,
        ReportRequest = 24,
    }

  
    public enum GetRRMode
    {
        GetNormal = 1,          //读取一个对象属性请求        [1] GetRequestNormal;    读取一个对象属性的响应       [1]GetResponseNormal，
        GetNext = 2,           //读取分帧响应的下一个数据块请求	[5] GetRequestNext;      分帧响应一个数据块           [5]GetResponseNext
        GetWithList = 3,       // 读取若干个对象属性请求      [2] GetRequestNormalList;读取若干个对象属性的响应     [2]GetResponseNormalList   
       
    }

    public enum SetRRMode
    {     
       SetNormal = 1,       //设置一个对象属性请求        
       SetFirstDatablock = 2,
       SetDatablock = 3,
       SetList = 4,  // 设置若干个对象属性请求     
       SetListFirstDatablock = 5,
    }

    public enum SetREMode
    {
        SetNormal = 1,            //	[1] IMPLICIT Set-Response-Normal,
        SetDatablock = 2,           //	[2] IMPLICIT Set-Response-Datablock,
        SetLastDatablock = 3,         //	[3]IMPLICIT Set-Response-Last-Datablock,
        SetLastDatablockList = 4,	 //   [4]IMPLICIT Set-Response-Last-Datablock-With-List,
        SetList = 5
    }

    public enum ActionRRMode
    {
        ActionNormal = 1, //[1] IMPLICIT Action-Request-Normal,
        ActionNextPblock = 2,    // [2] IMPLICIT Action-Request-Next-Pblock,
        ActionList = 3,   // IMPLICIT Action-Request-With-List,
        ActionFirstPblock = 4, //[4] IMPLICIT Action-Request-With-First-Pblock,
        ActionListFirstPblock = 5, //[5] IMPLICIT Action-Request-With-List-And-First-Pblock,
        ActionPblock = 6

    }
    public enum ActionREMode
    {
        ActionNormal = 1, //  [1] IMPLICIT Action-Response-Normal,
        ActionPblock = 2,    //[2] IMPLICIT Action-Response-With-Pblock,
        ActionList = 3,      //[3] IMPLICIT Action-Response-With-List,
        ActionNextPblock = 4
    }

    public enum DAR    //DataAccessResult  //Action-Result只是在此基顾上少了17，18，用同一个枚举
    {
        成功 = 0,
        硬件错误 = 1 ,          //HardwareFault = 1,
        临时错误 = 2,          //TemporaryFailure = 2,
        读写拒绝 = 3,           //ReadWriteDenied = 3,
        对象未定义 = 4,         //ObjectUndefined = 4,
        对象数据类不一致 = 9,   //ObjectClassInconsistent = 9,
        对象不能用 = 11,        //ObjectUnavailable = 11,
        类型不匹配 = 12,         //TypeUnmatched = 12,
        访问范围冲突 = 13,         //ScopeOfAccessViolated = 13,
        数据块不能用 = 14,        //DataBlockUnavailable = 14,
        忽略长数据抄读 = 15,      //LongGetAborted = 15,
        进程中没有长数据抄读 = 16,  //NoLongGetInProgress = 16,
        忽略长数据设置 = 17,        //LongSetAborted = 17,
        进程中没有长数据设置 = 18,  //NoLongSetInProgress = 18,
        其它原因 = 250              //OtherReason = 250
        
    }

   public enum RequirContext{
       LN_NoCipher = 1, // LN_NoCiphering     // Context_id(1)：logical name referencing, no ciphering used;
      // SN_NoCipher = 2,   // SN_NoCiphering    // Context_id(2)：暂时屏蔽
       LN_Cipher = 3,   //   LN_Ciphering    //  Context_id(3)：
     //  SN_Cipher = 4,   //   SN_Ciphering       // Context_id(4)：
   }

   //安全验证等级
   public enum Authentication
   {
       NoAuth = 0,   
       LLS = 1,
       HLS = 2,
       HLS_MD5 = 3,
       HLS_SHA_1 = 4,
       HLS_GMAC = 5,
       HLS_SHA_256 = 6,
       HLS_ECDSA = 7,

   }

   public enum SecurityPolicy{
       无认证 = 0,         //(0) nothing,
       需认证 = 1,           //(1) all messages to be authenticated,
       需加密 = 2,           //(2) all messages to be encrypted,
       需认证加密 = 3     //(3) all messages to be authenticated and encrypted
   }


   public enum SecuritySuite
   {
       GCM_128 = 0,         //(0)AES-GCM-128 authenticated encryption and AES-128 key wrap
       GCM_128_SHA_256 = 1,           //(1) AES-GCM-128 authenticated encryption, ECDSA P-256 digital signature, ECDH P-256 key agreement, SHA-256 hash, V.44 compression and AES-128 key wrap
       GCM_256_SHA_384 = 2,           //AES-GCM-256 authenticated encryption, ECDSA P-384 digital signature, ECDH P-384 key agreement, SHA-384 hash, V.44 compression and AES-256 key wrap
       
   }
   public enum GetResult
   {
       data = 0,       //数据      [1]   Data
       AccessResult = 1,     //错误信息  [0]   DAR，
   }
 
    public enum DLLConnResult{
        OK = 0,
        NOK = 1,
        NO_RESPONSE = 2
    }

    public enum DicReqReason
    {
        Normal = 0,
        Urgent = 1,
        User_Defined = 30,
    }

    public enum DicResReason
    {
        Normal = 0,
        Not_Finished = 1,
        User_Ddefined = 30,

    }

    public enum TIUnit
    {
        S = 0,      //（0），
        minute = 1,      //（1），
        hour = 2,      //（2），
        day = 3,      //（3），
        month = 4,      //（4），
        year = 5      //（5）

    }

    public enum AssociationResult  //Association-result 
    {
        Accepted = 0, //accepted (0),
        永久拒绝 = 1, //RejectedPermanent (1),永久拒绝
        暂时拒绝 = 2,   // RejectedTransient (2) 暂时拒绝

    }

    public enum StateError
    {
        服务不允许 = 1 , //Service_Not_Allowed = 1,
        未知的服务 = 2 , //Service_Unknown = 2
    }

    public enum ServiceError
    {
        操作不可能 = 1,   // Operation_Not_Possible = 1,
        服务不允许 = 2,   // Service_Not_Supported = 2,
        其他原因  = 3,    //Other_Reason
        Pdu太长 = 4,      //Pdu_Too_long 
        解密错误= 5,      //Deciphering_Error 
        调用计数器错误 = 6 //Invocation_Counter_Error
    }


    public enum EnuAerviceUser
    {
		无 = 0,
        没有给出错误原因 = 1,     //No_Reason_Given = 1,
        应用语境名称不支持 = 2, //  ContextName_Not_Supported = 2,
        密码认证机制名称不识别 = 11, //MechanismName_Not_Recognised = 11,
        需要密码认证机制名称 = 12,   //MechanismName_Required = 12,
        密码认证失败 = 13,           //Authentication_Failure = 13,
        需要密码认证 = 14 ,          //Authentication_Required = 14
    }

    public enum EnuServiceProvider
    {
        无 = 0,
        没有给出错误原因 = 1,    //No_Reason_Given = 1,
        不是通用ACSE版本 = 2,     //No_Common_Acse_Version = 2
    }


    //负荷曲线排序方法 确省值  fifo
    public enum ProfileSort
    {
        fifo = 1,           //(first in first out)，
        lifo = 2,           //(last in first out)，
        largest = 3,
        smallest = 4,
        nearest_to_zero = 5,
        farest_from_zero = 6
    }

    //时钟基准,基本定时信息的来源
    public enum ClockBase
    {
        NotDefined = 0, //（未定义）
        InternalCrys = 1,//（内部晶振）
        Mains50Hz = 2,        //（50Hz主频）
        Mains60Hz = 3,         //（60Hz主频）
        GPS = 4,         //(全球定位系统)
        RadioControl = 5  //（无线控制）
    }

    //当前连接的状态
    public enum AssociationStatus
    {
        NonAssociated = 0,
        Asspending = 1,
        Associated = 2
    }

    //单操作时间表类型
    public enum SingleScheduleType
    {
        T1Wildcard = 1,   //(1) execution_time 的大小=1；允许日期通配符
        TSameNoWildcard = 2,//(2) execution_time 的大小=n；所有时间值相同；不允许日期通配符
        TSameWildcard = 3,//(3) execution_time 的大小=n；所有时间值相同；允许日期通配符
        TNoSameNoWildcard = 4,//(4) execution_time 的大小=n；时间值可能不同；不允许日期通配符
        TNoSameWildcard = 5//(5) execution_time 的大小=n；时间值可能不同；允许日期通配符

    }


    public enum UnitsEnum
    {
        year = 1,
        month = 2,
        week = 3,
        d = 4,
        h = 5,
        min = 6,
        s = 7,
        degree = 8,
        oC = 9,
        currency = 10,
        m = 11,
        m_per_s = 12,//米每秒
        m3 = 13,
        //m3 = 14,
        m3_per_h = 15,
        // 立方米每小时 = 16,
        m3_per_24h = 17,
        // 立方米每24小时 = 18,
        l = 19,
        kg = 20,
        N = 21,
        Nm = 22,
        P = 23,
        bar = 24,
        J = 25,
        J_per_h = 26,
        W = 27,        
        VA = 28,
        var = 29,
        Wh = 30,
        VAh = 31,
        varh = 32,      
        A = 33,
        C = 34,        
        V = 35,
        V_per_m = 36,
        F = 37,
        Ω = 38,
        Ωm2_per_m = 39,
        Wb = 40,
        T = 41,
        A_per_m = 42,
        H = 43,
        Hz = 44,
        l_per_Wh = 45,
        l_per_varh = 46,
        l_per_VAh = 47,
        V2h = 48,
        A2h = 49,
        kg_per_s = 50,
        siemens = 51,
        K = 52,
        l_per_V2h = 53,
        l_per_A2h = 54,
        l_per_m3 = 55,
        Ah = 57,
        Wh_per_m3=60,
        J_per_m3 = 61,
        Mol_per = 62,
        g_per_m3 = 63,
        Pa_s = 64,
        J_per_kg = 65,
        dBm = 70,
        dbμV = 71,
        dB = 72
    }

    public enum BaudRate
    {
        _300bps = 0,
        _600bps = 1,
        _1200bps = 2,
        _2400bps = 3,
        _4800bps = 4,       
        _9600bps = 5,
        _19200bps = 6,
        _38400bps = 7,
        _57600bps = 8,
        _115200bps = 9,
        自适应 = 255

    }

    public enum ParityBit
    {
        None = 0, //无校验（0），
        Odd = 1,  //奇校验（1），
        Even = 2  //偶校验（2）
    }

    public enum DataBit
    {
        _5 = 5,
        _6 = 6,
        _7 = 7,
        _8 = 8
    }

    public enum StopBit
    {
        _1 = 1,
        _2 = 2
    }

    public enum KeyId { 
       glo_Unicast_Key = 0 ,     //global-unicast-encryption-key (0), 
       glo_Broadcast_Key = 1,    //global-broadcast-encryption-key (1)
       auth_key = 2,          // (2) authentication key,
       master_key = 3,         //(3) master key (KEK)

    }

    public enum KekId
    {
        Master_Key = 0      
        
    }

    public enum image_transfer_status{
       transfer_not_initiated = 0, //(0) Image transfer not initiated,
       transfer_initiated = 1,     //(1) Image transfer initiated,
       verification_initiated = 2,     //(2) Image verification initiated,
       verification_successful = 3,     //(3) Image verification successful,
       verification_failed = 4 ,     //(4) Image verification failed,
       activation_initiated = 5,     //(5) Image activation initiated,
       activation_successful = 6,    // (6) Image activation successful,
       activation_failed = 7,       // (7) Image activation failed
}

    //////////// 安全认证相关///////////////////

    //////////////////////////////////////////    





}
